<include file="../header" />
<body class="J_scroll_fixed">
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp&key=FO5BZ-2AC2G-ACAQV-I5BD3-YX65K-76BUB"></script>
    <script src="http://open.map.qq.com/apifiles/v1.0/app.js?v=1.0.131203.1" type="text/javascript"></script>
    <script type="text/javascript">
    $(function() {
        var shopDescription = UE.getEditor('shopDescription',{
                    initialFrameHeight:300,
                    initialContent : '{$shop.shop_description}',
                    serverUrl :'{:U("shop/ueditorUpload")}'
                });
        var coachDescription = UE.getEditor('coachDescription',{
                    initialFrameHeight:300,
                    initialContent : '{$shop.coach_description}',
                    serverUrl :'{:U("shop/ueditorUpload")}'
                });        
        var warmReminder = UE.getEditor('warmReminder',{
                    initialFrameHeight:300,
                    initialContent : '{$shop.warm_reminder}',
                    serverUrl :'{:U("shop/ueditorUpload")}'
                });
        $("button#send").click(function() {

            var address = $("input[name=address]").val();

            var geocoder = new soso.maps.Geocoder();

            geocoder.geocode({'address': address}, function(results, status) {
                if (status == soso.maps.GeocoderStatus.OK) {
                    $("input[name=latitude]").val(results.location.lat);
                    $("input[name=longtitude]").val(results.location.lng);

                    $("input[name=shopDescription]").val(shopDescription.getContent());
                    $("input[name=coachDescription]").val(coachDescription.getContent());
                    $("input[name=warmReminder]").val(warmReminder.getContent());
                    
                    $("form").submit();
                } else {
                    alert("检索没有结果，原因: " + status);
                }
            });

        });

        $("button#upload").click(function(){     
            //上传文件
            $.ajaxFileUpload({
                url:"{:U('shop/uploadImage')}", //处理图片脚本
                secureuri: false,
                fileElementId: 'fileToUpload', //file控件id
                dataType: 'json',
                success: function(data, status) {
                    $("input[name=imageUrl]").val(data);
                    $("img[name=preShow]").attr("src", data);
                },
                error: function(data, status, e) {
                    alert(e);
                }
            })
        })
        
    });
</script>
<script type="text/javascript"  src="__TMP__/assets/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript"  src="__TMP__/assets/js/ueditor/ueditor.all.min.js"></script>
	<div class="wrap jj">
		<div class="common-form">
			<form method="post" class="form-horizontal J_ajaxForm" action="{:U('shop/edit_post')}">
                            <input type="hidden" name="id" value="{$shop.shop_id}" />
				<fieldset>
					<div class="control-group">
						<label class="control-label">店铺名称：</label>
						<div class="controls">
							<input type="text" class="input" name="shopName" value="{$shop.shop_name}">
						</div>
					</div>
                                        <div class="control-group">
                                            <label class="control-label">标题图片:</label>
                                            <div class="controls">
                                                    <input id="fileToUpload" type="file" name="fileToUpload" style="width:170px;">
                                                    <button type="button" class="btn btn-primary" id="upload">上传</button>
                                                    <input type="hidden" name="imageUrl" value="{$shop.image_url}" />
                                            </div>
					</div>
                                        <div class="control-group">
                                            <label class="control-label">图片预览:</label>
                                            <div class="controls">
                                                <img src="{$shop.image_url}" name="preShow" style="width:400px;height:200px;" />
                                            </div>
                                        </div>
                                        <div class="control-group">
						<label class="control-label">空闲人数上限：</label>
						<div class="controls">
							<input type="text" class="input" name="comfortableNumber" value="{$shop.comfortable_number}">
						</div>
					</div>
                                        <div class="control-group">
						<label class="control-label">良好人数上限：</label>
						<div class="controls">
							<input type="text" class="input" name="fineNumber" value="{$shop.fine_number}">
						</div>
					</div>
                                        <div class="control-group">
						<label class="control-label">每年价格：</label>
						<div class="controls">
							<input type="text" class="input" name="yearPrice" value="{$shop.year_price}">
						</div>
					</div>
                                    <div class="control-group">
						<label class="control-label">每季价格：</label>
						<div class="controls">
							<input type="text" class="input" name="seasonPrice" value="{$shop.season_price}">
						</div>
					</div>
                                    <div class="control-group">
						<label class="control-label">每月价格：</label>
						<div class="controls">
							<input type="text" class="input" name="monthPrice" value="{$shop.month_price}">
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">地址：</label>
						<div class="controls">
                                                        <input type="hidden" class="input" name="latitude" value="">
                                                        <input type="hidden" class="input" name="longtitude" value="">
							<input type="text" class="input" name="address" value="{$shop.address}">
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">座机电话：</label>
						<div class="controls">
							<input type="text" class="input" name="phoneNumber" value="{$shop.phone_number}">
						</div>
					</div>
                                    <div class="control-group">
                                        <label class="control-label">店铺详情：</label>
                                        <div class="controls">
                                            <input type="hidden" name="shopDescription" />
                                            <script type="text/plain" id="shopDescription" name="shopDescription"></script>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">教练介绍：</label>
                                        <div class="controls">
                                            <input type="hidden" name="coachDescription" />
                                            <script type="text/plain" id="coachDescription" name="coachDescription"></script>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">温馨提示：</label>
                                        <div class="controls">
                                            <input type="hidden" name="warmReminder" />
                                            <script type="text/plain" id="warmReminder" name="warmReminder"></script>
                                        </div>
                                    </div>
				</fieldset>
				<div class="form-actions">
					<button type="button" class="btn btn-primary" id="send">更新</button>
					<a class="btn" href="__URL__">返回</a>
				</div>
			</form>
		</div>
	</div>
	<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>